package com.example.demo.uitls;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.Map;

public class MessageUtils {
    public static String responseMessage(String username, String content) {
        ObjectMapper mapper = new ObjectMapper();
        Map<String, String> messageMap = new HashMap<>();
        messageMap.put("username", username);
        messageMap.put("content", content);
        try {
            return mapper.writeValueAsString(messageMap);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }
}